package org.example.big_data.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import java.time.LocalDateTime;

public class Category {
    @NotNull(groups = {Update.class,Delete.class}) //只属于Update分组的校验，Add有关的参数校验不校验这个ID值
    private Integer id;//主键ID
    @NotEmpty(groups = {Update.class,Add.class})  //同时属于Update和Add分组的校验
    private String categoryName;//分类名称
    @NotEmpty(groups = {Update.class,Add.class})
    private String categoryAlias;//分类别名
    private Integer createUser;//创建人ID
    //限制查询结果赋值为对象时的时间属性的格式
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;//创建时间
    //限制查询结果赋值为对象时的时间属性的格式
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;//更新时间

    public void setId(Integer id) {
        this.id = id;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public void setCategoryAlias(String categoryAlias) {
        this.categoryAlias = categoryAlias;
    }

    public void setCreateUser(Integer createUser) {
        this.createUser = createUser;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getId() {
        return id;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public String getCategoryAlias() {
        return categoryAlias;
    }

    public Integer getCreateUser() {
        return createUser;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    //功能优化：定义分组接口，1.实现参数的分组校验,接口名即分组名
    public interface Add{}

    public interface Update{}

    public interface Delete{}
}
